import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

class ChartItem extends StatelessWidget {
  final String avatar;
  final String title;
  final String sub;
  final String time;
  final GestureTapCallback? onTap;
  const ChartItem({Key? key, required this.avatar, this.onTap, required this.title, required this.sub, required this.time}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Material(
        color: Colors.white,
        child: Container(
          padding:
          EdgeInsets.only(top: 10.h, bottom: 10.h, left: 16.w, right: 16.w),
          decoration: BoxDecoration(
              color: Colors.transparent,
              border: Border(
                  top: BorderSide(color: const Color(0xffEDEDED), width: 0.5.w))),
          child: Row(
            children: [
              CircleAvatar(
                  radius: 20.w,
                  backgroundImage: CachedNetworkImageProvider(
                      avatar
                  )
              ),
              Expanded(
                child: Container(
                  height: 38.h,
                  padding: EdgeInsets.only(
                      left: 10.w
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          Expanded(child: Text(title, style: TextStyle(
                              color: const Color(0xff323233),
                              fontSize: 15.sp,
                              fontWeight: FontWeight.w600
                          ))),
                          Text(time, style: TextStyle(
                              color: const Color(0xffB9B9B9),
                              fontSize: 12.sp
                          ),)
                        ],
                      ),
                      Container(
                        alignment: Alignment.centerLeft,
                        child: Text(sub,
                            textAlign: TextAlign.left,
                            style: TextStyle(
                                fontSize: 13.sp,
                                color: const Color(0xffACACAC),
                                overflow: TextOverflow.ellipsis
                            )),
                        margin: EdgeInsets.only(right: 30.w),
                      )
                    ],
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
